
#include <map>
#include "http_response.h"

using comm::http::custorm::CHttpResponse;


CHttpResponse::CHttpResponse(void)
{
}

void CHttpResponse::SetStatusLine(uint32_t dwStatusCode, 
		const std::string& sProtocolVersion, 
		const std::string& sReasonPhrase)
{
	m_dwStatusCode     = dwStatusCode;
	m_sProtocolVersion = sProtocolVersion;
	m_sReasonPhrase    = sReasonPhrase;
}

const std::string& CHttpResponse::GetProtocolVersion(void) const
{
    return m_sProtocolVersion;
}

uint32_t CHttpResponse::GetStatusCode(void) const
{
    return m_dwStatusCode;
}

const std::string& CHttpResponse::GetReasonPhrase(void) const
{
    return m_sReasonPhrase;
}

void CHttpResponse::AddHeader(const std::string& sName, const std::string& sValue)
{
    m_mmapRespHeaders.insert(std::pair<std::string, std::string>(sName, sValue));
}

const void CHttpResponse::GetAllHeader(std::multimap<std::string, std::string>& mmapRespHeaders) const
{
    mmapRespHeaders = m_mmapRespHeaders;
}

bool CHttpResponse::HasHeader() const
{
    return !m_mmapRespHeaders.empty();
}


void CHttpResponse::SetBody(const std::string& sBody)
{
    m_sBody = sBody;
}

void CHttpResponse::AppendToBody(const std::string& sPart)
{
    m_sBody += sPart;
}

const std::string& CHttpResponse::GetBody(void) const
{
    return m_sBody;
}

void CHttpResponse::Reset()
{
	m_dwStatusCode = 0;
    m_sBody.clear();
	m_sProtocolVersion.clear();
   	m_sReasonPhrase.clear();
	m_mmapRespHeaders.clear();
}

